package org.jeecg.tender.project.constant;

import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.enums.BaseEnum;

public interface NoticeConstant {

//    String NOTICE_TEMPLATE = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>Title</title><style>table{border-collapse:collapse;width:100%%;margin:20px 0}th,td{border:1px solid#000;padding:10px;text-align:center}th{background-color:#f2f2f2;font-weight:bold}tr:nth-child(even){background-color:#f9f9f9}tr:hover{background-color:#e6e6e6}</style></head><body><div><p>经初步筛选，今日推荐商机见下表，请业务部门尽快评估，并请领导层决策。</p></div><table><tr><th>招标项目名称</th><th>发布时间</th><th>截止时间</th><th>招标网址</th><th>命中关键字</th><th>招标公告地址</th></tr>%s</table></body></html>";
    String NOTICE_TEMPLATE = "<!DOCTYPE html><html lang=\"zh\"><head><meta charset=\"UTF-8\"><title>商机推荐</title>"
            + "<style>table{border-collapse:collapse;width:100%%;margin:20px 0;table-layout:fixed;}"
            + "th,td{border:1px solid #000;padding:10px;text-align:center;word-wrap:break-word;word-break:break-all;}"
            + "th{background-color:#f2f2f2;font-weight:bold;}tr:nth-child(even){background-color:#f9f9f9;}"
            + "tr:hover{background-color:#e6e6e6;}th:nth-child(1){width:30%%;}th:nth-child(2),th:nth-child(3){width:15%%;}"
            + "th:nth-child(4),th:nth-child(5),th:nth-child(6){width:10%%;}</style>"
            + "</head><body><div><p>经初步筛选，今日推荐商机见下表，请业务部门尽快评估，并请领导层决策。</p></div>"
            + "<table><tr><th>招标项目名称</th><th>发布时间</th><th>截止时间</th><th>招标网址</th><th>命中关键字</th><th>招标公告地址</th></tr>%s</table></body></html>";


    /**
     * 通知方式二进制下标
     * @author: qiang.zhou
     * @date: 2025/3/10 15:39
     **/
    enum NoticeIdx implements BaseEnum<Integer, String> {
        PHONE(7, "短信通知"),
        EMAIL(6, "邮件通知"),
        ;

        private Integer code;
        private String name;
        NoticeIdx(Integer code, String name) {
            this.code = code;
            this.name = name;
        }
        @Override
        public Integer getCode() {
            return this.code;
        }

        @Override
        public String getName() {
            return this.name;
        }

        /**
         * 获取二进制中指定下标的开关状态
         * @author: qiang.zhou
         * @date: 2025/3/10 15:34
         * @param binStr
         * @return java.lang.Integer
         **/
        public Integer findBin(String binStr) {
            if (StringUtils.isBlank(binStr)) {
                return null;
            }
            return Integer.valueOf(String.valueOf(binStr.charAt(this.code)));
        }

        /**
         * 根据通知方式开关，生成二进制字符串
         * @author: qiang.zhou
         * @date: 2025/3/10 15:46
         * @param phone
         * @param email
         * @return java.lang.String
         **/
        public static String getBinStr(Integer phone, Integer email) {
            return String.format("%6s%d%d", 0, email, phone).replace(" ", "0");
        }
    }

}
